*** REPLICATION FILE ***

*** "Election Timing across Autocracy and Democracy (ETAD): 
*** A new dataset of national election dates"
*** Electoral Studies 96 (2025) 102964
*** by Masaaki Higashijima, Naoki Shimizu, Hidekuni Washida, and Yuki Yanai
*** https://doi.org/10.1016/j.electstud.2025.102964

*** Replication code for the section "3. Conditional off-schedule election timing"
*** Code for this section written by Hidekuni Washida (washida@toyo.jp)
*** December 24, 2024

*** For the raw data and the R package of ETAD, please visit Yuki Yanai's webpage:
*** https://yukiyanai.github.io/data_etad/

****************
*** Cleaning ***
****************

gen ele_lh= 0
recode ele_lh 0=1 if etype2=="parliament"

tostring sche_date, gen(sche_datechar)
gen sche_datet = date(sche_datechar, "YMD")
format sche_datet %td
tostring held_date, gen(held_datechar)
gen held_datet = date(held_datechar, "YMD")
format held_datet %td

* Timing
gen dif = held_datet - sche_datet if sche_date!=.

gen dif60 = 0 if dif!=.
recode dif60 0=1 if dif<-60
recode dif60 0=2 if dif>60

label define label_dis 0 "On schedule" 1 "Early" 2 "Delayed"
label value dif60 label_dis

gen EarlyDelayNo = dif60
replace EarlyDelayNo = 3 if reason == 7
replace EarlyDelayNo = . if reason==1 | reason==2 | reason==3 | reason==4 | reason==5 | reason==6 
replace EarlyDelayNo = . if reason==7 & dif60==2
label define label_earlydelayno 0 "On schedule" 1 "Early" 2 "Delayed" 3 "No confidence"
label value EarlyDelayNo label_earlydelayno

gen EarlyNo = EarlyDelayNo
recode EarlyNo 2=. 3=2
label define label_earlyno 0 "On schedule" 1 "Early" 2 "No confidence"
label value EarlyNo label_earlyno

gen EarlyDelay = EarlyDelayNo
recode EarlyDelay 3=. 
label value EarlyDelay label_dis

* Dissolution power
gen ldissolution = l_v2exdjdshg
replace ldissolution = l_v2exdfdshs if l_v2exdjdshg==.

egen ldissolution3 = cut(ldissolution), group(3)
gen ldissolution3D = ldissolution3==2 if ldissolution3!=.

label var ldissolution3D "Strong dissolution"

* Composition
gen l_maj = 0 if l_seatshare!=.
recode l_maj 0=1 if l_seatshare>.5

gen l_single=0 if l_numparty!=.
recode l_single 0=1 if l_numparty==1

gen l_composition = 0 if l_single!=. & l_maj!=.
recode l_composition 0=1 if l_single==1 & l_maj==0
recode l_composition 0=2 if l_single==1 & l_maj==1

label define label_composition 0 "Coalition" 1 "Single-minority" 2 "Single-majority"
label values l_composition label_composition

* Growth
egen mean_lgrowth = mean(l_growth), by(ccode)
egen sd_lgrowth = sd(l_growth), by(ccode)
gen dif_lgrowth = l_growth - mean_lgrowth
gen std_lgrowth = (l_growth - mean_lgrowth)/sd_lgrowth


****************
*** Figure 2 ***
****************

* democracy: only 20 Delay cases
mlogit EarlyNo std_lgrowth i.ldissolution3D i.termlength5 i.ele_lh std_l_lngdppc if e_boix_regime==1 , cluster(ccode)
estat ic
margins, dydx(*) post
coefplot (, keep(*:1._predict) legend(position(6) rows(1)) label(On-schedule) mcolor(black) msymbol(oh) levels(90 95) ciopts(color(black black) recast(rcap))) ///
             (, keep(*:2._predict) label(Early) mcolor(red) msymbol(d) msize(small) levels(90 95) ciopts(color(red red) recast(rcap)))  ///
             (, keep(*:3._predict) label(No confidence) mcolor(green) msymbol(c) msize(small) levels(90 95) ciopts(color(green green) recast(rcap)))  ///  
, swapnames xline(0, lc(gs10)) legend(rows(1) region(lcolor(white))) drop(_cons)  title("Democracy", size(mlarge)) saving(dem.gph, replace)  yline(1.5 2.5 3.5 4.5 5.5 , lcolor(gs10) lwidth(thin)) ylab(,notick) grid(none) xlabel(-.5(.25).5)  byopts(legend(pos(6) col(3)))  

sum i.EarlyNo std_lgrowth ldissolution3D termlength5 ele_lh std_l_lngdppc if e(sample)==1

* autocracy: only 6 No cases
mlogit EarlyDelay std_lgrowth i.ldissolution3D i.termlength5  i.ele_lh  std_l_lngdppc   if e_boix_regime==0, cluster(ccode)
estat ic
margins, dydx(*) post
coefplot (, keep(*:1._predict) legend(position(6) rows(1)) label(On-schedule) mcolor(black) msymbol(oh) levels(90 95) ciopts(color(black black) recast(rcap))) ///
             (, keep(*:2._predict) label(Early) mcolor(red) msymbol(d) msize(small) levels(90 95) ciopts(color(red red) recast(rcap)))  ///
             (, keep(*:3._predict) label(Delayed) mcolor(blue) msymbol(s) msize(small) levels(90 95) ciopts(color(blue blue) recast(rcap)))  ///
,swapnames xline(0, lc(gs10)) legend(rows(1) region(lcolor(white))) drop(_cons )  title("Autocracy", size(mlarge)) saving(aut.gph, replace)   yline(1.5 2.5 3.5 4.5 5.5,  lcolor(gs10) lwidth(thin))  ylab(,notick) grid(none)   ysc(alt) xlabel(-.5(.25).5) byopts(legend(pos(6) col(3)))  

sum i.EarlyDelay std_lgrowth ldissolution3D termlength5 ele_lh std_l_lngdppc if e(sample)==1

* democracy: additional variables
mlogit EarlyNo std_lgrowth i.ldissolution3D i.termlength5 i.ele_lh std_l_lngdppc i.l_composition lcollectiveD if e_boix_regime==1 , cluster(ccode)
estat ic
margins, dydx(*) post
coefplot (, keep(*:1._predict) legend(position(6) rows(1)) label(On-schedule) mcolor(black) msymbol(oh) levels(90 95) ciopts(color(black black) recast(rcap))) ///
             (, keep(*:2._predict) label(Early) mcolor(red) msymbol(d) msize(small) levels(90 95) ciopts(color(red red) recast(rcap)))  ///
             (, keep(*:3._predict) label(No confidence) mcolor(green) msymbol(c) msize(small) levels(90 95) ciopts(color(green green) recast(rcap)))  ///  
, swapnames xline(0, lc(gs10)) legend(rows(1) region(lcolor(white))) drop(_cons)  title("Democracy", size(mlarge)) saving(dem2.gph, replace)  yline(1.5 2.5 3.5 4.5 5.5 6.5 7.5, lcolor(gs10) lwidth(thin)) ylab(,notick) grid(none) xlabel(-.5(.25).5)  byopts(legend(pos(6) col(3)))   

sum i.EarlyNo std_lgrowth ldissolution3D termlength5 ele_lh std_l_lngdppc i.l_composition lcollectiveD if e(sample)==1

* autocracy: additional variables
mlogit EarlyDelay std_lgrowth i.ldissolution3D i.termlength5  i.ele_lh  std_l_lngdppc i.l_composition lcollectiveD  if e_boix_regime==0, cluster(ccode)
estat ic
margins, dydx(*) post
coefplot (, keep(*:1._predict) legend(position(6) rows(1))  label(On-schedule) mcolor(black) msymbol(oh) levels(90 95) ciopts(color(black black) recast(rcap))) ///
             (, keep(*:2._predict) label(Early) mcolor(red) msymbol(d) msize(small) levels(90 95) ciopts(color(red red) recast(rcap)))  ///
             (, keep(*:3._predict) label(Delayed) mcolor(blue) msymbol(s) msize(small) levels(90 95) ciopts(color(blue blue) recast(rcap)))  ///
,swapnames xline(0, lc(gs10)) legend(rows(1) region(lcolor(white))) drop(_cons )  title("Autocracy", size(mlarge)) saving(aut2.gph, replace)   yline(1.5 2.5 3.5 4.5 5.5  6.5 7.5,  lcolor(gs10) lwidth(thin))  ylab(,notick) grid(none)   ysc(alt) xlabel(-.5(.25).5) byopts(legend(pos(6) col(3)))  

sum i.EarlyDelay std_lgrowth ldissolution3D termlength5 ele_lh std_l_lngdppc i.l_composition lcollectiveD if e(sample)==1

graph combine dem.gph aut.gph dem2.gph  aut2.gph 


****************
*** Figure 3 ***
****************

* Democracy
mlogit EarlyNo c.std_lgrowth##i.ldissolution3D##i.l_composition  i.termlength5 std_l_lngdppc i.ele_lh  if e_boix_regime==1, cluster(ccode) 
estat ic
sum std_lgrowth if e(sample)==1, detail 
margins, at(std_lgrowth=(-3.5(.1)3.4) ldissolution3D=(1 0) l_composition  =(0 1 2))
marginsplot, graphregion(fcolor(white)) plotregion(fcolor(white)) xlabel(none) ciopt(color(%50)) recast(line) recastci(rarea)   yline(0, lcolor(black)) xtitle("GDP pc growth (standardized)") xlabel(-3(1)3) saving(sinminor.gph, replace)  by(ldissolution3D l_composition) byopts(legend(pos(6) row(1)))

sum i.EarlyNo  std_lgrowth ldissolution3D i.l_composition termlength5 std_l_lngdppc ele_lh if e(sample)==1


****************
*** Figure 4 ***
****************

* collective
mlogit EarlyNo c.std_lgrowth##i.lcollectiveD##i.ldissolution3D i.l_composition  i.termlength5 std_l_lngdppc i.ele_lh if e_boix_regime==1, cluster(ccode) 
estat ic
sum std_lgrowth if e(sample)==1, detail 

margins, at(std_lgrowth=(-3.5(.1)2.6) ldissolution3D=(0) lcollectiveD=(0 1) )
marginsplot, graphregion(fcolor(white)) plotregion(fcolor(white)) xlabel(none) ciopt(color(%50)) recast(line) recastci(rarea)   yline(0, lcolor(black)) xtitle("GDP pc growth (standardized)") xlabel(-3.5(1)3) saving(dem3a.gph, replace)  by( lcollectiveD ) byopts(legend(pos(6) row(1)))

margins, at(std_lgrowth=(-3.5(.1)2.6) ldissolution3D=(1) lcollectiveD=(0 1) )
marginsplot, graphregion(fcolor(white)) plotregion(fcolor(white)) xlabel(none) ciopt(color(%50)) recast(line) recastci(rarea)   yline(0, lcolor(black)) xtitle("GDP pc growth (standardized)") xlabel(-3.5(1)3) saving(dem3b.gph, replace)  by( lcollectiveD ) byopts(legend(pos(6) row(1)))

sum i.EarlyNo std_lgrowth lcollectiveD ldissolution3D i.l_composition termlength5 std_l_lngdppc ele_lh if e(sample)==1

mlogit EarlyDelay c.std_lgrowth##c.lcollectiveD i.l_composition i.termlength5 std_l_lngdppc i.ele_lh if e_boix_regime==0, cluster(ccode) 
estat ic
sum std_lgrowth if e(sample)==1, detail 
margins, at(std_lgrowth=(-2.9(.1)2.8) lcollectiveD=(0 1))
marginsplot, graphregion(fcolor(white)) plotregion(fcolor(white)) xlabel(none) ciopt(color(%50)) recast(line) recastci(rarea)   yline(0, lcolor(black)) xtitle("GDP pc growth (standardized)") xlabel(-3.5(1)3 ) saving(aut3.gph, replace)  by(lcollectiveD) byopts(legend(pos(6) row(1)))

sum i.EarlyDelay std_lgrowth lcollectiveD i.l_composition termlength5 std_l_lngdppc ele_lh if e(sample)==1

graph combine dem3a.gph dem3b.gph aut3.gph
